#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    m_pDispDrm = new  ldDRMSDI(NULL);
    if(m_pDispDrm)
    {
        m_pDispDrm->start();

    }

    m_pCapture = new SdiCatprue(NULL);
    if(m_pCapture)
    {
        m_pCapture->start();
    }

    connect(m_pCapture,SIGNAL(ProcFrame(stVFrame*)),m_pDispDrm,SLOT(OnRecNewFrame(stVFrame*)));

}

MainWindow::~MainWindow()
{
    delete ui;
    if(m_pCapture)
    {
        m_pCapture->Stop();
        m_pCapture->wait();
        SAFE_DELETE(m_pCapture);
    }

    if(m_pDispDrm)
    {
        m_pDispDrm->Stop();
        m_pDispDrm->wait();
        SAFE_DELETE(m_pDispDrm);
    }
}


void MainWindow::OnHandleOneSecond()
{
    char  cMsgBuff[STR_BUFF_LEN] = {0};
    sprintf(cMsgBuff,"cap tv[%3d] display %3d",m_pCapture->GetFps(),m_pDispDrm->GetFps());
    printf(cMsgBuff);
}

